﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace gChartSharp
{
    /// <summary>
    /// http://code.google.com/apis/chart/#solid_fill
    /// </summary>
    public class ChartSolidFill : IFill
    {

        /// <summary>
        /// The name of the API
        /// </summary>
        public string Name { get { return "chf"; } }


        /// <summary>
        /// Always return what type of fill we are in case we forget
        /// </summary>
        public FillType FillType { get { return FillType.s; } }


        /// <summary>
        /// Where in the chart to apply the fill
        /// </summary>
        public SolidFillType SolidFillType { get; set; }


        /// <summary>
        /// The color of the fill
        /// </summary>
        public Color Color { get; set; }


        /// <summary>
        /// Constructor to initialize all properties
        /// </summary>
        /// <param name="solidFillType"></param>
        /// <param name="color"></param>
        public ChartSolidFill(SolidFillType solidFillType, Color color)
        {
            this.SolidFillType = solidFillType;
            this.Color = color;
        }


        /// <summary>
        /// Hide the default constructor
        /// </summary>
        private ChartSolidFill() { }


        /// <summary>
        /// Render the text of the API
        /// </summary>
        /// <returns></returns>
        public string Render()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(String.Format("&{0}={1},{2},{3}", this.Name, this.SolidFillType.ToString(), this.FillType.ToString(), ChartHelper.ConvertColorToHex(this.Color)));
            //sb.Append(this.SolidFillType.ToString());
            //sb.Append(",");
            //sb.Append(this.FillType.ToString());
            //sb.Append(",");
            //sb.Append(ChartHelper.ConvertColorToHex(this.Color));

            return sb.ToString();
        }
    }


    public enum SolidFillType
    {
        /// <summary>
        /// background fill
        /// </summary>
        bg,

        /// <summary>
        /// chart area fill
        /// </summary>
        c,

        /// <summary>
        /// apply transparency to the whole chart
        /// </summary>
        a
    }
}
